package dao.admin.impl;

import dao.BaseDao;
import dao.admin.ManagerAddDao;
import dao.admin.ManagerDelDao;
import entity.Manager;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * ManagerDelDaoImpl
 *
 * @author ChenYanMei
 * @version 2023/9/5
 */
public class ManagerDelDaoImpl extends BaseDao implements ManagerDelDao {
    /**
     * 删除管理员信息
     * @param id
     * @return
     */
    @Override
    public int del(int id) {
        // 准备参数
        Connection connection = super.getConnection();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        int result = 0;
        String sql = "delete from manager where id=?";
        try {
            pstmt = connection.prepareStatement(sql);
            pstmt.setInt(1, id);
            result = pstmt.executeUpdate();
        } catch (SQLException e) {
           e.printStackTrace();
        }finally {
            closeAll(null, pstmt, connection);
        }
        return result;
    }
}
